package com.aiju.cash.core.api;

import com.aiju.app.config.ConfigManager;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import java.io.File;

/**
 * @author: 佐为
 * @date: 2016-11-24 19:14
 * @version: V1.0
 * @Description: 店铺
 */
public class ShopApi {

    private String updateShop = ConfigManager.INIT_SERVER_HOST + "/shop/update";
    private String upload = ConfigManager.INIT_SERVER_HOST + "/shop/upload";
    private String save = ConfigManager.INIT_SERVER_HOST + "/shop/save";
    private String get = ConfigManager.INIT_SERVER_HOST + "/shop/get";


    /**
     * 店铺信息接口
     */
    public void get(String id, String token, StringCallback callback) {
        OkHttpUtils
                .post()
                .url(get)
                .addParams("id", id)
                .addParams("token", token)
                .build()
                .execute(callback);
    }

    /**
     * 店铺添加
     */
    public void saveShop(String userName, String nickName, StringCallback callback) {
        OkHttpUtils
                .post()
                .url(save)
                .addParams("name", userName)
                .addParams("nickName", nickName)
                .build()
                .execute(callback);
    }

    /**
     * 店铺名称修改接口
     */
    public void updateShop(String id, String nickName, StringCallback callback) {
        OkHttpUtils
                .post()
                .url(updateShop)
                .addParams("id", id)
                .addParams("shopName", nickName)
                .build()
                .execute(callback);
    }

    /**
     * 店铺头像修改接口
     */
    public void updateShopImage(String id, String imageUrl, StringCallback callback) {
        OkHttpUtils
                .post()
                .url(updateShop)
                .addParams("id", id)
                .addParams("imageUrl", imageUrl)
                .build()
                .execute(callback);
    }

    /**
     * 店铺优惠券开关
     */
    public void updateShopDiscount(String id, String isDiscount, StringCallback callback) {
        OkHttpUtils
                .post()
                .url(updateShop)
                .addParams("id", id)
                .addParams("isDiscount", isDiscount)
                .build()
                .execute(callback);
    }

    /**
     * 店铺上传头像
     */
    public void uploadShopImage(String token, File file, StringCallback callback) {
        OkHttpUtils
                .post()
                .url(upload)
                .addFile("uploadFile", "code.jpg", file)
                .addParams("token", token)
                .build()
                .execute(callback);
    }
}
